#!/usr/bin/python

#http://docs.python.org/lib/os-file-dir.html

import os
import re
import sys
import shutil

def wai():
    ''' where am i - routine (when paths are not working under py2exe)
    '''
    #print 'sys.executable', sys.executable
    #print 'os.getcwd', os.getcwd()
    ##sys.executable C:\AFT\data\drive_r\Clients\prague-apps\DGL\.DGL\main.exe
    ##os.getcwd C:\WINDOWS\system32

    se_p, se_f = os.path.split(sys.executable)
    se_p += '\x5C'
    og_p = os.getcwd() + '\x5C'

    if se_f not in ('pythonw.exe', 'python.exe', 'python'):
        #return se_p
        return re.sub('\\\\', '/', se_p)
    else:
        #return og_p
        return re.sub('\\\\', '/', og_p)

def examples():
    print 'current working directory>> \n',os.getcwd()
    print 'files listing>> \n', os.listdir('.')
    print 'change working directory> \n', os.chdir('c:/')
    print 'files listing>> \n', os.listdir('.')


    print 'change working directory> \n', os.chdir('c:/AFT')
    print 'current working directory>> \n',os.getcwd()
    """
    # temp file demonstration
    #http://docs.python.org/lib/os-newstreams.html#os-newstreams
    #has problem: permission denied

    tempf = os.tmpfile()
    tempf.write('hello word')
    print tempf.read()
    #tempf.close()
    tempf = os.tmpfile()
    print tempf.read()
    """

    # copy file example
    shutil.copy('c:/AUTOEXEC.BAT', 'c:/AFT')
    # move file example
    shutil.move('c:/AFT/AUTOEXEC.BAT', 'c:/AFT/temp')

    # remove file
    #os.remove(path)
    # rename file
    #os.rename(src, dst)

if __name__=='__main__':
    ''' '''
    pass


